<template>
  <div>
    <el-select clearable
      v-model="model" :placeholder="`请选择${field.showName}`">
      <el-option
        v-for="item in flowStatusOption" :key="item.key"
        :value="item.key" :label="item.title"/>
    </el-select>
  </div>
</template>
<script setup>
import {reactive, ref, unref} from 'vue';
import {isEmpty} from '@/utils/CommonUtils';

const props = defineProps({
  field: {
    type: Object,
    default: () => ({}),
  }
});
const model = ref();
const flowStatusOption = reactive([
  {
    key: '0',
    title: '未发起'
  },
  {
    key: '1',
    title: '运行中'
  },
  {
    key: '2',
    title: '流程通过'
  },
  {
    key: '3',
    title: '流程不通过'
  }
]);

function getSearchFieldValue(searchData) {
  let value = unref(model);
  if (isEmpty(value)) return;
  searchData.eq.push({
    fieldName: props.field.tableFieldName,
    value
  });
}

function resetField() {
  model.value = undefined;
}

defineExpose({
  resetField,
  getSearchFieldValue
});
</script>
